﻿using System;

class TribonacciTriangle
{
    static void Main()
    {
        //Telerik Academy Exam 1 @ 27 Dec 2012

        long first = long.Parse(Console.ReadLine());
        long second = long.Parse(Console.ReadLine());
        long third = long.Parse(Console.ReadLine());
        int rows = int.Parse(Console.ReadLine());

        long result = 0;
        int colomns = rows;

        if (rows == 2)
        {
            Console.WriteLine(first);
            Console.WriteLine(second + " " + third);
        }
        if (rows > 2)
        {
            Console.WriteLine(first);                       //печат 1 ред
            Console.WriteLine(second + " " + third);        //печат 2 ред

            for (int i = 3; i <= rows; i++)                 //печат 3 и сл.редове
            {
                result = first + second + third;
                Console.Write(result);
                int currentRow = i;
                first = second;
                second = third;
                third = result;

                for (int j = 2; j <= currentRow; j++)  
                {
                    result = first + second + third;
                    Console.Write(" " + result);
                    first = second;
                    second = third;
                    third = result;                   
                }
                Console.WriteLine();
            }           
        }
    }
}
